package com.yywz.bean;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class ImageViewerBean extends JLabel{
	
	private static final int XPREFSIZE = 200;
	
	private static final int YPREFSIZE = 200;
	
	private File file = null;
	
	public ImageViewerBean() {
		setBorder(BorderFactory.createEtchedBorder());
	}
	
	public void setFileName(String fileName){
		try {
			file = new File(fileName);
			setIcon(new ImageIcon(ImageIO.read(file)));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public String getFileName() {
		if (file == null) return "";
		else return file.getPath();
	}
}
